import request from '@/utils/request'



export default {
    //查询全部
    getContractsList(searchModel) {
        return request({
            url: '/contracts',
            method: 'get',

            params: {
                pageNo: searchModel.pageNo,
                pageSize: searchModel.pageSize,
                contractsName: searchModel.contractsName,
                userId: searchModel.userId
            }
        });
    },
    //新增
    addcontracts(contracts) {
        return request({
            url: '/contracts',
            method: 'post',
            data: contracts
        });
    },
    //删除
    delletecontracts(id) {
        return request({
            url: `/contracts/${id} `,
            method: 'delete',

        });
    },
    //修改
    updatecontracts(contracts) {
        return request({
            url: '/contracts',
            method: 'put',
            data: contracts
        });
    },
    savecontracts(contracts) {
        if(contracts.id==null&&contracts.id==undefined){
        return this.addcontracts(contracts);
        }
         return this.updatecontracts(contracts);   
       
    },
    //查询  by  id
    getcontractsById(id) {
        return request({
            url: `/contracts/${id} `,
            method: 'get',

        });
    },
    getAllContractsList() {
        return request({
            url: '/contracts/all',
            method: 'get'
        });
    },
    fetchUsers() {
        return request({
            url: '/user',
            method: 'get'
        });
    },
    

}